<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div class="nav">
        <a href="/home">首页</a>
        <a href="/service">服务</a>
        <a href="/mine">个人中心</a>
    </div>
    <div class="content"></div>
</body>

</html>
<script>
    var a = document.querySelectorAll('a')
    a.forEach((item) => {
        item.onclick = function (e) {
            e.preventDefault()   
            history.pushState({ title: '', url: '' }, '',this.href)
          switch(location.pathname){
            case '/home':home_yemian(); break
            case '/service':service_yemian(); break
            case '/mine':mine_yemian(); break
          }
        }
    })

    function home_yemian() {
        document.querySelector('.content').innerHTML = '首页的内容'
    }
    function service_yemian() {
        document.querySelector('.content').innerHTML = '服务的内容'
    }
    function mine_yemian() {
        document.querySelector('.content').innerHTML = '个人中心的内容'
    }
</script>